
import React, { useRef, useState } from 'react'

 const Hook1 = () => {
     const [count,setCount]=useState(0)
     const [ Msg,setMsg]=useState('daydayup')
     const [ word,setword]=useState('hook is so rasy')
     const text =useRef()
     const changeword =e =>{
        setword(e.target.value)
        console.log(text);
     }

  return (
    <div>Hook_1
        <h2>定义组件内部初始化的值</h2>
        <h2>count--{count}</h2>
        <h2>Msg--{Msg}</h2>
        <h2>Word--{word}</h2>
        <hr></hr>
        <button onClick={()=>setCount(count+1)}>countadd</button>
        <button onClick={()=>setMsg('努力才有收获')}>努力才有收获</button>
       <input type="text" value={word} onChange={changeword} />
       <input type="text" ref={text} onChange={()=>setword(text.current.value)} />
    </div>
  )
}

export  default Hook1;